package com.witsight.hibernate.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;

import com.witsight.hibernate.converter.GenderConverter;

/**   
 * 说明：[]
 * @Title: City.java 
 * @Package com.witsight.hibernate.model 
 * @See: []
 * Copyright: Copyright (c) 2017
 * Company:sany huax witsight team by product
 * @author: fuyp  
 * @date: 2017年9月12日 下午2:43:31 
 * @version: V1.0
 *
 */
@Entity
public class City extends BaseEntity {
	/** 
	 * 说明：[]
	 * @See: serialVersionUID[]
	 * @Fields serialVersionUID : 
	 */ 
	
	private static final long serialVersionUID = 2514138645953013638L;
	public enum PhoneType {
	    LAND_LINE,
	    MOBILE;
	}
	
	public enum Gender {

	    MALE( 'M' ),
	    FEMALE( 'F' );

	    private final char code;

	    Gender(char code) {
	        this.code = code;
	    }

	    public static Gender fromCode(char code) {
	        if ( code == 'M' || code == 'm' ) {
	            return MALE;
	        }
	        if ( code == 'F' || code == 'f' ) {
	            return FEMALE;
	        }
	        throw new UnsupportedOperationException(
	            "The code " + code + " is not supported!"
	        );
	    }

	    public char getCode() {
	        return code;
	    }
	}
	
	@Column(nullable = false)
	private String name;

	@Column(nullable = true)
	private String state;

	@Column(nullable = true)
	private String country;

	@Column(nullable = true)
	private String map;
	
	
    private PhoneType type;
    
    private Date testDate;
   
    public Gender gender;
    @Convert( converter = GenderConverter.class )
    public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	@Column(name = "phone_type")
    @Enumerated(EnumType.STRING)
	public PhoneType getType() {
		return type;
	}

	public void setType(PhoneType type) {
		this.type = type;
	}

	public City() {
	}

	public City(String name, String country) {
		super();
		this.name = name;
		this.country = country;
	}

	public String getName() {
		return this.name;
	}

	public String getState() {
		return this.state;
	}

	public String getCountry() {
		return this.country;
	}

	public String getMap() {
		return this.map;
	}
	
	
	public void setName(String name) {
		this.name = name;
	}

	public void setState(String state) {
		this.state = state;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public void setMap(String map) {
		this.map = map;
	}

	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		return true;
	}

	public Date getTestDate() {
		return testDate;
	}

	public void setTestDate(Date testDate) {
		this.testDate = testDate;
	}

}
